package com.jsu.clubmanagementsystem.model.vo.club;

import cn.hutool.json.JSONUtil;
import com.jsu.clubmanagementsystem.model.entity.Club;
import com.jsu.clubmanagementsystem.model.vo.clubAnnouncement.ClubAnnouncementVO;
import com.jsu.clubmanagementsystem.model.vo.user.UserVO;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

@Data
public class ClubVO implements Serializable {
    /**
     * 社团id
     */
    private Long id;

    /**
     * 社团名称
     */
    private String clubName;

    /**
     * 社长
     */
    private UserVO userVO;

    /**
     * 标签列表（json 数组）
     */
    private List<String> tags;

    /**
     * 社团公告
     */
    private ClubAnnouncementVO clubAnnouncementVo;

    /**
     * 社团简介
     */
    private String introduction;

    /**
     * 社团人数
     */
    private Integer memberCount;

    public static ClubVO objToVo(Club club) {
        if (club == null) {
            return null;
        }
        ClubVO clubVO = new ClubVO();
        BeanUtils.copyProperties(club, clubVO);
        clubVO.setTags(JSONUtil.toList(club.getTags(), String.class));
        //需要在调用处理userVo和公告Vo
        return clubVO;
    }

    private static final long serialVersionUID = 1L;
}
